package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class POWER extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 2)
      return Primitive.ERROR_NAME;
    Object localObject1 = paramArrayOfObject[0];
    Object localObject2 = paramArrayOfObject[1];
    if ((localObject1 instanceof Number) && (localObject2 instanceof Number))
      return FunctionHelper.parsePrimitiveDouble(Math.pow(((Number)localObject1).doubleValue(), ((Number)localObject2).doubleValue()));
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "POWER(number,power): 返回指定数字的乘幂。\nNumber:底数，可以为任意实数。\nPower:指数。参数number按照该指数次幂乘方。\n备注:\n    可以使用符号“^”代替POWER，如: POWER(5,2)等于5^2。\n示例:\nPOWER(6,2)等于36。\nPOWER(14,5)等于537824。\nPOWER(4,2/3)等于2.519842100。\nPOWER(3,-2.3)等于0.079913677。";
  }

  public String getEN()
  {
    return "POWER(number,power): Returns the result of a number raised to a power.\nNumber is the base number. It can be any real number.\nPower is the exponent to which the base number is raised.\n\nRemarks:\n    The \"^\" operator can be used instead of POWER to indicate to what power the base number is to be raised, such as in 5^2 equals POWER(5,2).\n\nExample:\n   POWER(6,2) = 36\n   POWER(14,5) = 537824\n   POWER(4,2/3) = 2.519842100\n   POWER(3,-2.3) = 0.079913677";
  }
}